import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:toolkit/components/tool-btn.dart';
import 'package:toolkit/global.dart';
import 'package:toolkit/iconfont.dart';
import 'package:toolkit/toolkit/aes.dart';
import 'package:toolkit/toolkit/daxie.dart';
import 'package:toolkit/toolkit/qrcode.dart';
import 'package:toolkit/toolkit/ruler.dart';

class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            colors: [
              Global.primaryColor,
              Global.primaryColor.withOpacity(.4),
            ],
          ),
        ),
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              SizedBox(height: 80),
              Container(
                width: 100,
                child: Image.asset('assets/images/icon.png'),
              ),
              SizedBox(height: 50),
              ToolButton(
                icon: IconFont.chizi,
                text: '尺子',
                onTap: () {
                  Navigator.push(context,
                      MaterialPageRoute(builder: (context) => RulerPage()));
                },
              ),
              SizedBox(height: 25),
              ToolButton(
                icon: IconFont.jiami,
                text: '文字加密解密',
                onTap: () {
                  Navigator.push(context,
                      MaterialPageRoute(builder: (context) => TextAESPage()));
                },
              ),
              SizedBox(height: 25),
              ToolButton(
                icon: IconFont.zhuanhuan,
                text: '数字大写转换',
                onTap: () {
                  Navigator.push(
                      context,
                      MaterialPageRoute(
                          builder: (context) => NumberDaxiePage()));
                },
              ),
              SizedBox(height: 25),
              ToolButton(
                icon: IconFont.erweima,
                text: '二维码生成',
                onTap: () {
                  Navigator.push(context,
                      MaterialPageRoute(builder: (context) => QrCodePage()));
                },
              ),
              SizedBox(height: 35),
            ],
          ),
        ),
      ),
    );
  }
}
